//package com.robot.orders.dao;
//
//import com.robot.orders.pojo.SubOrders;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//
//import java.util.List;
//
///**
// * subOrders数据访问接口
// *
// * @author lin
// */
//public interface SubOrdersDao extends JpaRepository<SubOrders, String>, JpaSpecificationExecutor<SubOrders> {
//    /**
//     * 根据memberId查找SubOrders
//     *
//     * @param memberId
//     * @param pageable
//     * @return
//     */
//    public Page<SubOrders> findAllByMemberIdAndDeletedAtIsNullOrderByCreatedAtDesc(String memberId, Pageable pageable);
//
//    /**
//     * 根据memberId和evaluating查找SubOrders
//     *
//     * @param memberId
//     * @param evaluating
//     * @param pageable
//     * @return
//     */
//    public Page<SubOrders> findAllByMemberIdAndEvaluatingAndDeletedAtIsNullOrderByCreatedAtDesc(String memberId, String evaluating, Pageable pageable);
//
//    /**
//     * 根据memberId和status查找SubOrders
//     *
//     * @param memberId
//     * @param status
//     * @param pageable
//     * @return
//     */
//    public Page<SubOrders> findAllByMemberIdAndStatusAndDeletedAtIsNullOrderByCreatedAtDesc(String memberId, String status, Pageable pageable);
//
//    /**
//     * 根据memberId和id查询SubOrders
//     *
//     * @param id
//     * @param memberId
//     * @return
//     */
//    public SubOrders findByIdAndMemberId(String id, String memberId);
//
//    /**
//     * 根据memberId和ordersId查询SubOrders
//     *
//     * @param ordersId
//     * @param memberId
//     * @return
//     */
//    public List<SubOrders> findAllByOrdersIdAndMemberId(String ordersId, String memberId);
//
//    /**
//     * 根据memberId查找会员累计支付成功的订单数
//     *
//     * @param memberId
//     * @return
//     */
//    @Query(value = "select count(*) from orders.sub_orders where member_id=? and status=1", nativeQuery = true)
//    public String findCountByMemberId(String memberId);
//
//    /**
//     * 根据memberId查找会员累计消费金额
//     *
//     * @param memberId
//     * @return
//     */
//    @Query(value = "select sum(pay_amount) from orders.sub_orders where member_id=? and status=1", nativeQuery = true)
//    public String findPayAmountByMemberId(String memberId);
//
//    /**
//     * 根据memberId和storeId查找会员累计消费金额
//     *
//     * @param memberId
//     * @param storeId
//     * @return
//     */
//    @Query(value = "select sum(pay_amount) from orders.sub_orders where member_id=? and store_id=? and status=1", nativeQuery = true)
//    public String findPayAmountByMemberIdAndStoreId(String memberId, String storeId);
//
//    /**
//     * 根据memberId查找会员累计节省金额
//     *
//     * @param memberId
//     * @return
//     */
//    @Query(value = "select sum(discount_amount) from orders.sub_orders where member_id=? and status=1", nativeQuery = true)
//    public String findDiscountAmountByMemberId(String memberId);
//
//
//    /**
//     * 根据storeId查找SubOrders
//     *
//     * @param storeId
//     * @param pageable
//     * @return
//     */
//    public Page<SubOrders> findAllByStoreIdAndDeletedAtIsNullOrderByCreatedAtDesc(String storeId, Pageable pageable);
//
//    /**
//     * 根据storeId,memberId和status查找SubOrders
//     *
//     * @param memberId
//     * @param storeId
//     * @param status
//     * @param pageable
//     * @return
//     */
//    public Page<SubOrders> findAllByMemberIdAndStoreIdAndStatusAndDeletedAtIsNullOrderByCreatedAtDesc(String memberId, String storeId, String status, Pageable pageable);
//
//    /**
//     * 根据storeId查找本月累计支付成功的订单数
//     *
//     * @param storeId
//     * @return
//     */
//    @Query(value = "SELECT count(*) FROM orders.sub_orders WHERE store_id=? and status=1 and DATE_FORMAT( created_at,'%Y%m') = DATE_FORMAT(CURDATE( ) ,'%Y%m')", nativeQuery = true)
//    public String findThisMonthCountByStoreId(String storeId);
//
//    /**
//     * 根据storeId查找累计消费金额
//     *
//     * @param storeId
//     * @return
//     */
//    @Query(value = "select sum(pay_amount) from orders.sub_orders where store_id=? and status=1", nativeQuery = true)
//    public String findPayAmountByStoreId(String storeId);
//
//    /**
//     * 根据storeId查找今天订单
//     *
//     * @param storeId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where store_id=? and status=1 and TO_DAYS(NOW()) - TO_DAYS(created_at) =0", nativeQuery = true)
//    public Page<SubOrders> findAllByStoreIdAndToday(String storeId, Pageable pageable);
//
//    /**
//     * 根据storeId查找昨天订单
//     *
//     * @param storeId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where store_id=? and status=1 and TO_DAYS(NOW()) - TO_DAYS(created_at) =1", nativeQuery = true)
//    public Page<SubOrders> findAllByStoreIdAndYesterday(String storeId, Pageable pageable);
//
//    /**
//     * 根据storeId查找最近7日订单
//     *
//     * @param storeId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where store_id=? and status=1 and DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(created_at)", nativeQuery = true)
//    public Page<SubOrders> findAllByStoreIdAndWeek(String storeId, Pageable pageable);
//
//    /**
//     * 根据storeId查找总订单
//     *
//     * @param storeId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where store_id=? and status=1", nativeQuery = true)
//    public Page<SubOrders> findAllByStoreIdAndTotal(String storeId, Pageable pageable);
//
//
//    /**
//     * 根据agentId查找今天订单
//     *
//     * @param agentId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where agent_id=? and status=1 and TO_DAYS(NOW()) - TO_DAYS(created_at) =0", nativeQuery = true)
//    public Page<SubOrders> findAllByAgentIdAndToday(String agentId, Pageable pageable);
//
//    /**
//     * 根据agentId查找昨天订单
//     *
//     * @param agentId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where agent_id=? and status=1 and TO_DAYS(NOW()) - TO_DAYS(created_at) =1", nativeQuery = true)
//    public Page<SubOrders> findAllByAgentIdAndYesterday(String agentId, Pageable pageable);
//
//    /**
//     * 根据agentId查找最近7日订单
//     *
//     * @param agentId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where agent_id=? and status=1 and DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(created_at)", nativeQuery = true)
//    public Page<SubOrders> findAllByAgentIdAndWeek(String agentId, Pageable pageable);
//
//    /**
//     * 根据agentId查找总订单
//     *
//     * @param agentId
//     * @param pageable
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where agent_id=? and status=1", nativeQuery = true)
//    public Page<SubOrders> findAllByAgentIdAndTotal(String agentId, Pageable pageable);
//
//    /**
//     * 根据agentId和createdAt查找总订单
//     *
//     * @param agentId
//     * @param createdAt
//     * @return
//     */
//    @Query(value = "select * from orders.sub_orders where agent_id=? and to_days(created_at)=to_days(?)", nativeQuery = true)
//    public List<SubOrders> findAllByAgentIdAndCreatedAt(String agentId, String createdAt);
//
//    /**
//     * 根据ordersId 获取到子订单列表
//     *
//     * @param ordersId
//     * @return
//     */
//    List<SubOrders> findByOrdersId(String ordersId);
//}
